package com.sbsj.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sbsj.mapper.AccountMapper;
import com.sbsj.models.TAccount;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class AccountService{

    private final AccountMapper accountMapper;

    public AccountService(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }

    public TAccount login(String username,String password)
    {
        LambdaQueryWrapper<TAccount> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TAccount::getLoginName,username);
        wrapper.eq(TAccount::getPassword,password);
        return accountMapper.selectOne(wrapper);
    }

    public TAccount selectAccountOne(String username)
    {
        LambdaQueryWrapper<TAccount> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TAccount::getLoginName,username);
        return accountMapper.selectOne(wrapper);
    }
}
